﻿Imports Entidades
Public Class frmDetallesObjeto
    Private obj As Objeto
    Private Sub btnConsultar_Click(sender As Object, e As EventArgs) Handles btnConsultar.Click
        If txtCodigo.Text = "" Then
            MessageBox.Show("No has introducido codigo de serie")
            Exit Sub
        End If
        obj = miGestion.detallesDeUnObjeto(txtCodigo.Text)
        If IsNothing(obj) Then
            MessageBox.Show("No existe ningun objeto con este codigo de serie")
            Exit Sub
        End If
        txtDescripcion.Text = obj.Descripcion
        Dim lista As List(Of Familia) = miGestion.obtenerFamilias
        For i As Integer = 0 To lista.Count - 1
            If lista(i).IdFamilia = obj.IdFamilia Then
                txtFamilia.Text = lista(i).Nombre
                Exit For
            End If
        Next
        txtValoracion.Text = obj.Valoracion
        txtTamaño.Text = obj.Tamaño
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If txtDescripcion.Text = "" Then
            MessageBox.Show("No se puede realizar")
            Exit Sub
        End If
        If txtCodigo.Text = "" Then
            MessageBox.Show("No se puede realizar")
            Exit Sub
        End If
        Dim cli As Cliente = miGestion.clientePorObjeto(obj)
        frmDetallesCliente.cliente = cli
        frmDetallesCliente.ShowDialog()

    End Sub

    Private Sub frmDetallesObjeto_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If txtDescripcion.Text = "" Then
            MessageBox.Show("No es posible realizar la operacion")
            Exit Sub
        End If
        Dim frm As New frmDarDeBaja
            frm.obj = obj
            frm.ShowDialog()


    End Sub
End Class